home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- BorderStyle = 1 'Fixed Single
- Caption = "Joystick Demo 32-bit"
- ClientHeight = 2490
- ClientLeft = 1575
- ClientTop = 2400
- ClientWidth = 8175
- Height = 2895
- Icon = "joy32.frx":0000
- Left = 1515
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2490
- ScaleWidth = 8175
- Top = 2055
- Width = 8295
- Begin VB.Timer Timer1
- Interval = 55
- Left = 7920
- Top = 60
- End
- Begin VB.CommandButton Command1
- Caption = "&Exit"
- Height = 315
- Left = 6840
- TabIndex = 11
- Top = 2100
- Width = 675
- End
- Begin VB.PictureBox PicBackground
- BackColor = &H00C0C0C0&
- Height = 2475
- Left = 0
- ScaleHeight = 2415
- ScaleWidth = 6075
- TabIndex = 0
- Top = 0
- Width = 6135
- Begin VB.Image imgCursor
- Height = 480
- Index = 3
- Left = 5520
- Picture = "joy32.frx":0442
- Top = 1080
- Visible = 0 'False
- Width = 480
- End
- Begin VB.Image imgCursor
- Height = 480
- Index = 2
- Left = 4920
- Picture = "joy32.frx":0884
- Top = 1080
- Visible = 0 'False
- Width = 480
- End
- Begin VB.Image imgCursor
- Height = 480
- Index = 1
- Left = 5520
- Picture = "joy32.frx":0CC6
- Top = 480
- Visible = 0 'False
- Width = 480
- End
- Begin VB.Image imgCursor
- Height = 480
- Index = 0
- Left = 4920
- Picture = "joy32.frx":1108
- Top = 480
- Visible = 0 'False
- Width = 480
- End
- Begin VB.Image imgJoyCursor
- Height = 480
- Left = 2040
- Picture = "joy32.frx":154A
- Top = 660
- Width = 480
- End
- Begin VB.Label lblButton
- Alignment = 2 'Center
- BackColor = &H00008000&
- BorderStyle = 1 'Fixed Single
- Caption = "Button 4"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000080&
- Height = 315
- Index = 3
- Left = 4680
- TabIndex = 4
- Top = 2040
- Width = 1335
- End
- Begin VB.Label lblButton
- Alignment = 2 'Center
- BackColor = &H00008000&
- BorderStyle = 1 'Fixed Single
- Caption = "Button 3"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000080&
- Height = 315
- Index = 2
- Left = 60
- TabIndex = 3
- Top = 2040
- Width = 1335
- End
- Begin VB.Label lblButton
- Alignment = 2 'Center
- BackColor = &H00008000&
- BorderStyle = 1 'Fixed Single
- Caption = "Button 2"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000080&
- Height = 315
- Index = 1
- Left = 4680
- TabIndex = 2
- Top = 60
- Width = 1335
- End
- Begin VB.Label lblButton
- Alignment = 2 'Center
- BackColor = &H00008000&
- BorderStyle = 1 'Fixed Single
- Caption = "Button 1"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000080&
- Height = 315
- Index = 0
- Left = 60
- TabIndex = 1
- Top = 60
- Width = 1335
- End
- End
- Begin VB.Label lblMinY
- Caption = "0"
- ForeColor = &H000000FF&
- Height = 195
- Left = 6960
- TabIndex = 17
- Top = 1740
- Width = 675
- End
- Begin VB.Label lblMaxY
- Caption = "0"
- ForeColor = &H000000FF&
- Height = 195
- Left = 6960
- TabIndex = 16
- Top = 1440
- Width = 675
- End
- Begin VB.Label lblMinX
- Caption = "0"
- ForeColor = &H000000FF&
- Height = 195
- Left = 6960
- TabIndex = 15
- Top = 1140
- Width = 675
- End
- Begin VB.Label lblMaxX
- Caption = "0"
- ForeColor = &H000000FF&
- Height = 195
- Left = 6960
- TabIndex = 14
- Top = 840
- Width = 675
- End
- Begin VB.Label lblY
- Caption = "0"
- ForeColor = &H000000FF&
- Height = 195
- Left = 6960
- TabIndex = 13
- Top = 480
- Width = 675
- End
- Begin VB.Label lblX
- Caption = "0"
- ForeColor = &H000000FF&
- Height = 195
- Left = 6960
- TabIndex = 12
- Top = 180
- Width = 675
- End
- Begin VB.Label Label2
- Caption = "MinY:"
- Height = 195
- Index = 5
- Left = 6360
- TabIndex = 10
- Top = 1740
- Width = 495
- End
- Begin VB.Label Label2
- Caption = "MaxY:"
- Height = 195
- Index = 4
- Left = 6360
- TabIndex = 9
- Top = 1440
- Width = 495
- End
- Begin VB.Label Label2
- Caption = "MinX:"
- Height = 195
- Index = 3
- Left = 6360
- TabIndex = 8
- Top = 1140
- Width = 495
- End
- Begin VB.Label Label2
- Caption = "MaxX:"
- Height = 195
- Index = 2
- Left = 6360
- TabIndex = 7
- Top = 840
- Width = 495
- End
- Begin VB.Label Label2
- Caption = "Y:"
- Height = 195
- Index = 1
- Left = 6360
- TabIndex = 6
- Top = 480
- Width = 495
- End
- Begin VB.Label Label2
- Caption = "X:"
- Height = 195
- Index = 0
- Left = 6360
- TabIndex = 5
- Top = 180
- Width = 495
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Dim JoyInfo As tJoyInfo
- Dim RangeWidth As Integer
- Dim RangeHeight As Integer
- ' Label Off Colors.
- Const DARKGREEN = &H8000&
- Const DARKRED = &H80&
- ' Label On Colors.
- Const BRIGHTGREEN = &HFF00&
- Const BRIGHTRED = &HFF&
- Private Sub Command1_Click()
- Unload Me
- End Sub
- Private Sub Form_Load()
- 'Center the form on the screen.
- Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
- ' Set the range for the little on-screen joystick cursor.
- RangeWidth = PicBackground.ScaleWidth - imgJoyCursor.Width
- RangeHeight = PicBackground.ScaleHeight - imgJoyCursor.Height
- End Sub
- Private Sub Timer1_Timer()
- Dim rc As Integer
- Dim i As Integer
- rc = GetJoystickPos(JOYSTICK1, JoyInfo)
- If rc = 0 Then
- imgJoyCursor.Left = RangeWidth * ((JoyInfo.X - JoyCaps.Xmin) / (JoyCaps.Xmax - JoyCaps.Xmin))
- imgJoyCursor.Top = RangeHeight * ((JoyInfo.Y - JoyCaps.Ymin) / (JoyCaps.Ymax - JoyCaps.Ymin))
- lblX = JoyInfo.X
- lblY = JoyInfo.Y
- lblMaxX = JoyCaps.Xmax
- lblMinX = JoyCaps.Xmin
- lblMaxY = JoyCaps.Ymax
- lblMinY = JoyCaps.Ymin
- For i = 0 To 3
- If JoyInfo.ButtonDown(i + 1) Then
- imgJoyCursor = imgCursor(i)
- If lblButton(i).BackColor <> BRIGHTGREEN Then
- lblButton(i).BackColor = BRIGHTGREEN
- lblButton(i).ForeColor = BRIGHTRED
- End If
- Else
- lblButton(i).BackColor = DARKGREEN
- lblButton(i).ForeColor = DARKRED
- End If
- Next
- End If
- End Sub
-